package prefuseDemos;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import javax.swing.JComponent;

import prefuse.data.Table;
import prefuse.util.ui.UILib;

public class dateConvert {

	public static void dayTimeToDate(int dayN) {
		int dayNumber = dayN - 1;
		Calendar origin = Calendar.getInstance();
		origin.set(1900, 00, 00); // init a origin calendar.
		origin.add(Calendar.DAY_OF_YEAR, dayNumber);
		SimpleDateFormat format = new SimpleDateFormat("yyyy,MM,dd");
		String dateString = format.format(origin.getTime());
		System.out.println("Today is:" + dateString);

	}

	public static void main(String[] args) throws ParseException {
		// DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
		// Date date = new Date();
		//
		// System.out.println(dateFormat.format(date));
		// // String dateString =dateFormat.format(date);
		// // int text = Integer.parseInt(dateFormat.format(dateString));
		// // System.out.println(dateString);
		//
		// String value = "2004-01-01";
		// int iii = new SimpleDateFormat("yyyy-MM-dd").parse(value).getDate();
		// System.out.println(iii);
		//
		// Date date1 = new Date();

		// int an = 37987;
		// System.out.println(dateFormat.format(0));

		// // (1) get today's date
		// Date today = Calendar.getInstance().getTime();
		//
		// // (2) create our date "formatter" (the date format we want)
		// SimpleDateFormat formatter = new SimpleDateFormat("0");
		//
		// // (3) create a new String using the date format we want
		// String folderName = formatter.format(dateFormat);
		//
		// // (4) this prints "Folder Name = 2009-09-06-08.23.23"
		// System.out.println("Folder Name = " + folderName);
		dayTimeToDate(40178);
		// Calendar now = Calendar.getInstance();
		// //now.setTime(new Date()); // set the date you want to calculate the
		// days for
		// Calendar origin = Calendar.getInstance();
		// origin.set(0,0,0); // init a temporary calendar.
		// int days=0;
		// // iterate from 1900 and check how many days are in the year, sum the
		// days
		// for (int i=1900; i < now.get(Calendar.YEAR);i++) {
		// origin.set(Calendar.YEAR, i);
		// int daysForThatYear = origin.getActualMaximum(Calendar.DAY_OF_YEAR);
		// days+=daysForThatYear;
		// System.out.printf("year:%4d days in the year:%3d, total days:%6d\n",i,daysForThatYear,days);
		// }
		// // check the number of days for the current year, and add to the
		// total of days
		// int daysThisYear = now.get(Calendar.DAY_OF_YEAR);
		// days+=daysThisYear;
		// System.out.printf("year:%4d days in the year:%3d, total days:%6d\n",now.get(Calendar.YEAR),daysThisYear,days);
		//

	}

}
